/**

 * 试管

 */
Testtube= Widget.extend({
	ctor:function(){
		this._super();
		this.init();
		this.setTag(TAG_TUBE);
	},
	init:function(){
		// 试管
		var testTube = new Button(this, 10, TAG_TESTTUBE, "#testtube.png", this.callback);
	},
	callback:function (p){
		var action=gg.flow.flow.action;
		var func=cc.callFunc(this.actionDone,this);
		switch(p.getTag()){
		case TAG_TESTTUBE:
			if(action==ACTION_DO1){
				var down=ll.run.getChildByTag(TAG_ICONSHELF).getChildByTag(TAG_SHELF_DOWN);
				down.runAction(cc.moveTo(0.6, cc.p(0,8)));
				
				var move1=cc.moveTo(0.6, cc.p(-50,169));
				var rota1=cc.rotateTo(0.6, 90);
				var move2=cc.moveTo(0.6,cc.p(-230,169));
				var rota2=cc.rotateTo(0.6, 100);
				var sequence=cc.sequence(move1,rota1,move2,cc.callFunc(function() {
					var show=new ShowTip("试管口向下倾斜，防止水蒸气倒流，\n导致试管破裂",cc.p(1000,350));
					var up=ll.run.getChildByTag(TAG_ICONSHELF).getChildByTag(TAG_SHELF_UP);
					var spa1=cc.spawn(cc.rotateTo(0.6, 10),cc.moveTo(0.6, cc.p(0,38)));
					up.runAction(spa1);
					var down=ll.run.getChildByTag(TAG_ICONSHELF).getChildByTag(TAG_SHELF_DOWN);
					var spa2=cc.spawn(cc.rotateTo(0.6, 10),cc.moveTo(0.6, cc.p(-4,3)));
					down.runAction(spa2);
				}, this),rota2,cc.delayTime(0.5),cc.callFunc(function() {
					gg.flow.next();
				}, this));
				p.runAction(sequence);				
			}else if(action==ACTION_DO2){
				var rota1=cc.rotateTo(0.6, 90);
				var move1=cc.moveTo(0.6, cc.p(-50,169));
				var rota2=cc.rotateTo(0.6, 0);
				var move3=cc.moveTo(0.6, cc.p(117,59));
				var rota3=cc.rotateTo(0.6, -110);
				var sequence=cc.sequence(cc.callFunc(function() {
					var up=ll.run.getChildByTag(TAG_ICONSHELF).getChildByTag(TAG_SHELF_UP);
					var spa1=cc.spawn(cc.rotateTo(0.6, 0),cc.moveTo(0.6, cc.p(0,43)));
					up.runAction(spa1);
					var down=ll.run.getChildByTag(TAG_ICONSHELF).getChildByTag(TAG_SHELF_DOWN);
					var spa2=cc.spawn(cc.rotateTo(0.6, 0),cc.moveTo(0.6, cc.p(0,8)));
					down.runAction(spa2);				
				}, this),rota1,move1,cc.callFunc(function() {
					ll.run.getChildByTag(TAG_ICONSHELF).removeFromParent();
					var fes=ll.run.getChildByTag(TAG_TUBE).getChildByTag(TAG_TESTTUBE).getChildByTag(TAG_FILTER_FE);
					var spa3=cc.spawn(cc.scaleTo(0.6, 1, 0.5),cc.moveTo(0.6, cc.p(21,21)));
					fes.runAction(spa3);
				}, this),rota2,move3,cc.callFunc(function() {
					var fes=ll.run.getChildByTag(TAG_TUBE).getChildByTag(TAG_TESTTUBE).getChildByTag(TAG_FILTER_FE);
					var spa3=cc.spawn(cc.scaleTo(0.6, 0.5, 1),cc.moveTo(0.6, cc.p(16,28)));
					var mo=cc.moveTo(1, cc.p(16,235));
					var spa4=cc.spawn(cc.moveTo(0.6, cc.p(8,252)),cc.scaleTo(0.6, 1.5,1));
					fes.runAction(cc.sequence(spa3,mo,spa4));
				}, this),rota3,cc.delayTime(1.8),cc.fadeOut(0),cc.callFunc(function() {
					gg.flow.next();
				}, this));
				p.runAction(sequence);
			}

			break;
		default:
			break;
		}
	},
	actionDone:function(p){
		switch (p.getTag()) {
		case TAG_TESTTUBE:			
			break;
		default:
			break;
		}
		gg.flow.next();
	}
})
